package com.com.wdy.invocation;

import java.util.concurrent.Callable;

/**
 * @ClassName: App
 * @Description: TODO
 * @Date: 2019/12/30 18:08
 * @Author: wangdy001
 * @Version: 1.0
 */
public class App {
    public static void main(String[] args) throws InterruptedException {
        ThreadSyncExector exector = new ThreadSyncExector();
        Callable<String> callable = ()->{
            return "200";
        };
        AsyncResult asyncResult = exector.startProcess(callable);
        asyncResult.await();
        System.out.println(asyncResult.isComplete());
        System.out.println(asyncResult.getValue());

        AsyncCallback<String> asyncCallback = (v, ex) -> {
            if(ex.isPresent()) {
                System.out.println("失败：" + ex.get().getMessage());
            } else {
                System.out.println("成功：" + v);
            }
        };
        asyncResult = exector.startProcess(callable, asyncCallback);
    }
}
